﻿@model IEnumerable<AvaliacaoOnline.Data.Cliente>

@{
    ViewBag.Title = "Avaliação Online - Clientes";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
<script type="text/javascript">
    $(function () {
        setTimeout(function () {
            $("#grid tr:odd td").css("background-color", "white");
            $("#grid tr:even td").css("background-color", "transparent");
        }, 0);
    });
    excluir = function (obj) {
        $.showMessage({
            message: "Deseja realmente excluir o cliente?",
            buttons: {
                "Sim": function () { $(obj).parent().submit(); },
                "Não": function () { $(this).dialog('close'); }
            }
        });
    }
</script>
@if(!String.IsNullOrWhiteSpace(ViewData["Message"] as string)){
<script type="text/javascript">
    $(function () {
        $.showMessage('@(Html.Raw(ViewData["Message"] as string))');
    });
</script>
}
}

<h3>Clientes</h3>

@if (Model.Count() == 0)
{
    <div class="quiet" style="width:100%; text-align:center;">Nenhum registro encontrado. (<a href="@Url.Action("Edit", "Cliente")">inserir cliente</a>)</div>
}
else
{ 
<table border="0" cellpadding="0" cellspacing="0" id="grid" style="width:100%" id="grid">
    <tr>
        <th style="width:85%">
            Nome
        </th>
        <th style="width:15%; text-align:center;">
            <a href="@Url.Action("Edit", "Cliente")">Inserir</a>
        </th>
    </tr>

    @foreach (var item in Model)
    {
    <tr>
        <td>
            @item.Nome
        </td>
        <td style="text-align:center;">
            <form action="@Url.Action("Edit", "Cliente")" method="post" style="display:inline;">
                <a href="#" onclick="$(this).parent().submit();">Editar</a>
                <input type="hidden" name="Id" value="@item.Id" />
                &nbsp;&nbsp;|&nbsp;&nbsp;
            </form>
            <form action="@Url.Action("Delete", "Cliente")" method="post" style="display:inline;">
                <a href="#" onclick="excluir(this);">Excluir</a>
                <input type="hidden" name="IdCliente" value="@item.Id" />
            </form>
        </td>
    </tr>
    }
</table>
}
